package de.cz3rwinski.haushaltsbuch;

import java.math.BigDecimal;
import java.text.NumberFormat;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;


public class Fragment_0 extends Fragment {
	public Fragment_0() {
	}
	
	//private TextView tv1;
	private View view;
	//private KPI_Ermittler kpi;
	//private int aktivesJahr,aktiverMonat,aktiverTag;
	public static final String ARG_SECTION_NUMBER = "section_number";

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		view = inflater.inflate(R.layout.dashboard_item, container, false);
		
		//WebView Konfiguration ////////////////////////////////////////////////////
		WebView browser=(WebView) view.findViewById(R.id.webView1);
		browser.getSettings().setJavaScriptEnabled(true);
		browser.setHorizontalScrollBarEnabled(false);
		browser.setVerticalScrollBarEnabled(false);
		browser.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
		int scale = (int) (125 * browser.getScale());
		browser.setInitialScale( scale );
		
		////////////////////////////////////////////////////////////////////////////
		Graphen graphen = new Graphen();
		
		String[] testarray = {"test1_70","test2_2","test3_33"};
	    
	    browser.loadData(graphen.Kreisdiagramm("Kategorien",testarray),"text/html", "UTF-8");

		return view;
	}
	
	public String toCurrency(double input) {
		double bestand = input * 100;
		BigDecimal parsed = new BigDecimal(bestand).setScale(2, BigDecimal.ROUND_FLOOR).divide(new BigDecimal(100), BigDecimal.ROUND_FLOOR);
		String formato = NumberFormat.getCurrencyInstance().format(parsed);
		return formato;
	}

	
	
}